package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MesBuyIn;
import com.ruoyi.system.service.IMesBuyInService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采购入库Controller
 * 
 * @author ruoyi
 * @date 2024-06-01
 */
@RestController
@RequestMapping("/system/in")
public class MesBuyInController extends BaseController
{
    @Autowired
    private IMesBuyInService mesBuyInService;

    /**
     * 查询采购入库列表
     */
    @PreAuthorize("@ss.hasPermi('system:in:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesBuyIn mesBuyIn)
    {
        startPage();
        List<MesBuyIn> list = mesBuyInService.selectMesBuyInList(mesBuyIn);
        return getDataTable(list);
    }

    /**
     * 导出采购入库列表
     */
    @PreAuthorize("@ss.hasPermi('system:in:export')")
    @Log(title = "采购入库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesBuyIn mesBuyIn)
    {
        List<MesBuyIn> list = mesBuyInService.selectMesBuyInList(mesBuyIn);
        ExcelUtil<MesBuyIn> util = new ExcelUtil<MesBuyIn>(MesBuyIn.class);
        util.exportExcel(response, list, "采购入库数据");
    }

    /**
     * 获取采购入库详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:in:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(mesBuyInService.selectMesBuyInById(id));
    }

    /**
     * 新增采购入库
     */
    @PreAuthorize("@ss.hasPermi('system:in:add')")
    @Log(title = "采购入库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesBuyIn mesBuyIn)
    {
        return toAjax(mesBuyInService.insertMesBuyIn(mesBuyIn));
    }

    /**
     * 修改采购入库
     */
    @PreAuthorize("@ss.hasPermi('system:in:edit')")
    @Log(title = "采购入库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesBuyIn mesBuyIn)
    {
        return toAjax(mesBuyInService.updateMesBuyIn(mesBuyIn));
    }

    /**
     * 删除采购入库
     */
    @PreAuthorize("@ss.hasPermi('system:in:remove')")
    @Log(title = "采购入库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(mesBuyInService.deleteMesBuyInByIds(ids));
    }


}
